﻿#region << 文件说明 >>

/*----------------------------------------------------------------
 * 命名空间：Vampirewal.Core.WebApi.Attributes
 * 唯一标识：afab538b-8c3a-4924-a8f2-93a888c48363
 * 文件名：HttpHandlerAttribute
 *
 * 创建者：杨程
 * 电子邮箱：235160615@qq.com
 * 创建时间：2023/9/28 15:18:54
 * 版本：V1.0.0
 * 描述：
 *
 * ----------------------------------------------------------------
 * 修改人：
 * 时间：
 * 修改说明：
 *
 * 版本：V1.0.1
 *----------------------------------------------------------------*/

#endregion << 文件说明 >>



namespace Vampirewal.Core.WebApi;

/// <summary>
/// 将方法标记为Http方法
/// </summary>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public sealed class VampirewalHttpAttribute : Attribute
{
    /// <summary>
    ///
    /// </summary>
    /// <param name="path">路由路径</param>
    /// <param name="method">Http请求方法</param>
    public VampirewalHttpAttribute(string path, HttpMethod method)
    {
        RoutePath = path;
        Method = method;
    }

    public HttpMethod Method { get; private set; }

    public string RoutePath { get; private set; }

    /// <summary>
    /// 描述信息
    /// </summary>
    public string Description { get; set; }

    /// <summary>
    /// 方法描述名称
    /// </summary>
    public string MethodName { get; set; }

    /// <summary>
    /// 是否在api文档内隐藏
    /// </summary>
    public bool ApiDocHidde { get; set; } = false;
}

/// <summary>
/// Http请求方法
/// </summary>
public enum HttpMethod
{
    GET,
    POST,
    DELETE
}


/// <summary>
/// 标记为VampirewalController，将自动添加进IOC容器中
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public sealed class VampirewalControllerAttribute : Attribute
{
    /// <summary>
    /// 
    /// </summary>
    /// <param name="registerType">注册方式</param>
    public VampirewalControllerAttribute(RegisterType registerType = RegisterType.Singleton)
    {
        this.registerType = registerType;
    }

    /// <summary>
    /// 注册方式
    /// </summary>
    public RegisterType registerType { get; private set; }

    /// <summary>
    /// 描述信息
    /// </summary>
    public string Description { get; set; }

    /// <summary>
    /// 描述控制器的名称
    /// </summary>
    public string ControllerName { get; set; }

    /// <summary>
    /// 是否在api文档内隐藏
    /// </summary>
    public bool ApiDocHidde {  get; set; }=false;
}

/// <summary>
/// 给方法中的参数添加描述信息
/// </summary>
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false)]
public sealed class VampirewalParameterAttribute : Attribute
{
    /// <summary>
    /// 
    /// </summary>
    /// <param name="description">描述信息</param>
    public VampirewalParameterAttribute(string description)
    {
        Description=description;
    }

    /// <summary>
    /// 描述信息
    /// </summary>
    public string Description { get; set; }
}